/*
 * Copyright (c) 2018. J4dream Created.
 */

package com.j4dream.property.leetcode.basic.design;

import java.util.LinkedList;

public class MinStack {
    /** initialize your data structure here. */

    private LinkedList<Integer> stack;

    public MinStack() {
        stack = new LinkedList<>();
    }

    public void push(int x) {
        stack.push(x);
    }

    public void pop() {
        stack.pop();
    }

    public int top() {
        return stack.getFirst();
    }

    public int getMin() {
        int min = Integer.MAX_VALUE;
        for (int s : stack) {
            min = Math.min(s, min);
        }
        return min;
    }
}
